package org.jwos.platform.desktop.service.internal;

import java.util.HashMap;
import java.util.Map;

import org.jwos.platform.desktop.service.DesktopManager;
import org.jwos.platform.domain.GlobalConfig;
import org.jwos.platform.domain.User;
import org.jwos.platform.service.SessionManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class StubDesktopManager implements DesktopManager {
	
	private SessionManager sessionManager;
	
	@Autowired
	public void init(SessionManager sessionManager) {
		this.sessionManager = sessionManager;
	}

	public String helloWorld(String msg) {
		return msg;
	}
	
	public Map getGlobalConfig(String sessionId) {
		Map result = new HashMap();
		
		User user = this.sessionManager.getUserBySessionId(sessionId);	
		Map userMap = new HashMap();
		userMap.put("userId", user.getUserId());
		userMap.put("userName", user.getUserName());
		userMap.put("email", user.getEmail());
		result.put("currentUser", userMap);
		
		GlobalConfig config = this.sessionManager.getGlobalConfig();
		result.put("globalConfig", config);		
		
		return result;
	}
}
